package com.marver.common.config;

import com.marver.common.handler.AccessRestrictiHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @description: 注册拦截器
 * @Author: Marver
 * @date: 2018-04-19 17:44
 **/
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {

    /**
     * 注册拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry){
        registry.addInterceptor(restrictiHandler()).addPathPatterns("/**");
        super.addInterceptors(registry);
    }

    @Bean
    public AccessRestrictiHandler restrictiHandler(){
        return new AccessRestrictiHandler();
    }
}
